package leetcode.code019.RemoveNthNodeFromEndofList;


import leetcode.helper.HelpDebug;
import leetcode.helper.HelpLinkedList;
import leetcode.helper.tree.ListNode;

public abstract class RemoveNthNodeFromEndofList implements IRemoveNthNodeFromEndofList {

	@Override
	public void debug1() {
//		输入：head = [1,2,3,4,5], n = 2
//		输出：[1,2,3,5]
		HelpDebug.printInputs("1,2,3,5", "1,2,3,4,5", 2);
		ListNode head = HelpLinkedList.array2list(new Integer[] { 1, 2, 3, 4, 5 });
		this.debug(head, 2);
	}

	@Override
	public void debug2() {
//		输入：head = [1], n = 1
//		输出：[]
		HelpDebug.printInputs("[]", "1", 1);
		ListNode head = HelpLinkedList.array2list(new Integer[] { 1 });
		this.debug(head, 1);
	}

	@Override
	public void debug3() {
//		输入：head = [1,2], n = 1
//		输出：[1]
		HelpDebug.printInputs("1", "1,2", 1);
		ListNode head = HelpLinkedList.array2list(new Integer[] { 1, 2 });
		this.debug(head, 1);
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	abstract public ListNode removeNthFromEnd(ListNode head, int n);

	@Override
	public void debug(ListNode head, int n) {
		ListNode p = this.removeNthFromEnd(head, n);
		HelpLinkedList.printLinkedList(p);
		System.out.println(" ");
	}

}
